package cn.hj.domain.activity.service.quota.chain.factory;

import cn.hj.domain.activity.service.quota.chain.IActivityChain;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
@Slf4j
public class DefaultActivityChainFactory {

    private final IActivityChain activityChain;

    public DefaultActivityChainFactory(Map<String, IActivityChain> activityChainMap) {
        activityChain = activityChainMap.get(ActionModel.activity_base_action.code);
        activityChain.appendNext(activityChainMap.get(ActionModel.activity_sku_stock_action.getCode()));
    }

    public IActivityChain openActionChain() {
        return this.activityChain;
    }


    @Getter
    @AllArgsConstructor
    public enum ActionModel {

        activity_base_action("activity_base_action", "活动的库存、时间校验"),
        activity_sku_stock_action("activity_sku_stock_action", "活动sku库存"),
        ;

        private final String code;
        private final String info;

    }
}
